package com.cmf.myproject.dal.mybatis.filters;

import java.util.Date;
import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.system.core.view.layui.table.TableViewReqDto;

import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public class TaskQueryFilter extends TableViewReqDto{

	//
	private Long id;
	//所属项目
	private Long projectId;
	//任务信息
	private String name;
	//开发人
	private String coder;
	//任务所属用户ID
    private Long userId;
	//任务开始时间
	private Date codeStart;
	//任务结束时间
	private Date codeEnd;
	//耗费工作日
	private Float timeCost;
	
	private List<String> status;
	//挂起原因
	private String pendingReson;
	//任务备注
	private String remarkTask;
	//
	private Date createTime;
	//
	private Date updateTime;
	
	private boolean exportFile = false;
	
	/**
	 * 任务开始时间
	 * jdbctype:timestamp
	 */
	private String codeStartStrStart;
	private String codeStartStrEnd;
	
	/**
	 * 任务结束时间
	 * jdbctype:timestamp
	 */
	private String codeEndStrStart;
	private String codeEndStrEnd;
	
	/**
	 * 
	 * jdbctype:timestamp
	 */
	private String createTimeStrStart;
	private String createTimeStrEnd;
	
	/**
	 * 
	 * jdbctype:timestamp
	 */
	private String updateTimeStrStart;
	private String updateTimeStrEnd;
	

	public String toQueryString() {
		StringBuilder param = new StringBuilder();
		/**
		 * jdbcType:bigint(20)
		 */
		if(getId() != null) {
			param.append("&id=");
			param.append(getId());
		}
		/**
		 * jdbcType:bigint(20)
		 */
		if(getProjectId() != null) {
			param.append("&projectId=");
			param.append(getProjectId());
		}
		/**
		 * 任务信息
		 * jdbcType:varchar(50)
		 */
		if(StringUtils.isNotBlank(getName())) {
			param.append("&name=");
			param.append(getName());
		}
		/**
		 * 开发人
		 * jdbcType:varchar(20)
		 */
		if(StringUtils.isNotBlank(getCoder())) {
			param.append("&coder=");
			param.append(getCoder());
		}
		/**
		 * jdbcType:timestamp
		 */
		if(StringUtils.isNotBlank(getCodeStartStrStart())) {
			param.append("&codeStartStrStart=");
			param.append(getCodeStartStrStart());
		}
		if(StringUtils.isNotBlank(getCodeStartStrEnd())) {
			param.append("&codeStartStrEnd=");
			param.append(getCodeStartStrEnd());
		}
		/**
		 * jdbcType:timestamp
		 */
		if(StringUtils.isNotBlank(getCodeEndStrStart())) {
			param.append("&codeEndStrStart=");
			param.append(getCodeEndStrStart());
		}
		if(StringUtils.isNotBlank(getCodeEndStrEnd())) {
			param.append("&codeEndStrEnd=");
			param.append(getCodeEndStrEnd());
		}
		/**
		 * jdbcType:enum('run','finish','pending','cancel')
		 */
		if(getStatus() != null) {
			param.append("&status=");
			param.append(getStatus());
		}
		/**
		 * 挂起原因
		 * jdbcType:varchar(255)
		 */
		if(StringUtils.isNotBlank(getPendingReson())) {
			param.append("&pendingReson=");
			param.append(getPendingReson());
		}
		/**
		 * 任务备注
		 * jdbcType:text
		 */
		if(StringUtils.isNotBlank(getRemarkTask())) {
			param.append("&remarkTask=");
			param.append(getRemarkTask());
		}
		/**
		 * jdbcType:timestamp
		 */
		if(StringUtils.isNotBlank(getCreateTimeStrStart())) {
			param.append("&createTimeStrStart=");
			param.append(getCreateTimeStrStart());
		}
		if(StringUtils.isNotBlank(getCreateTimeStrEnd())) {
			param.append("&createTimeStrEnd=");
			param.append(getCreateTimeStrEnd());
		}
		/**
		 * jdbcType:timestamp
		 */
		if(StringUtils.isNotBlank(getUpdateTimeStrStart())) {
			param.append("&updateTimeStrStart=");
			param.append(getUpdateTimeStrStart());
		}
		if(StringUtils.isNotBlank(getUpdateTimeStrEnd())) {
			param.append("&updateTimeStrEnd=");
			param.append(getUpdateTimeStrEnd());
		}
//		if(param.length() > 0)
//			return "?"+param.toString().substring(1, param.length());
//		else
		return param.toString();
	}
	
	@Override
	public String toString() {
		return toQueryString();
	}
}
